package com.example.a2022application;

import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * 开屏页面
 */
public class OpeningActivity extends BaseActivity {
    private Activity myActivity;
    private final int REQUEST_EXTERNAL_STORAGE = 1;
    //权限组（读写权限）
    private String[] PERMISSIONS_STORAGE = {
            Manifest.permission.WRITE_EXTERNAL_STORAGE,
            Manifest.permission.READ_EXTERNAL_STORAGE};

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        myActivity = this;
        //设置页面布局
        setContentView(R.layout.activity_opening);
        try {
            initView();
        } catch (IOException | JSONException e) {
            e.printStackTrace();
        }

    }
    private void initView() throws IOException, JSONException {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                if((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0){
                    finish();
                    return;
                }
                //两秒后跳转到主页面
                Intent intent2 = new Intent();
                intent2.setClass(OpeningActivity.this, MainActivity.class);
                startActivity(intent2);
                finish();
            }
        }, 2000);
    }



    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

    }

    @Override
    public void onBackPressed() {

    }
}
